package com.runnor.common.websys.system.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.runnor.common.websys.system.config.MybatisRedisCache;
import com.runnor.common.websys.system.entity.SysRole;
import com.runnor.common.websys.system.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.security.core.GrantedAuthority;

import java.util.List;

/**
 * @author runnor
 * @description 针对表【sys_role】的数据库操作Mapper
 * @createDate 2023-08-16 09:29:20
 * @Entity com.runnor.common.websys.system.entity.SysRole
 */
@Mapper
@CacheNamespace(implementation = MybatisRedisCache.class, eviction = MybatisRedisCache.class)

public interface SysRoleMapper extends BaseMapper<SysRole> {
    List<String> listPermissionByUserId(@Param("userId") String userId);

    @Insert("INSERT INTO `sys_role_menu_rela` VALUES(null,#{no},#{role})")
    void insertRoleMenu(@Param("no") String no, @Param("role") String role);

    @Delete("DELETE FROM `sys_role_menu_rela` WHERE role_no = #{no}")
    void deleteRoleMenu(@Param("no") String no);

    @Select("SELECT menu_no FROM `sys_role_menu_rela` WHERE role_no = #{no}")
    List<String> selectRoleMenu(@Param("no") String no);

    Page pages(Page page, @Param(Constants.WRAPPER) QueryWrapper<SysRole> queryWrapper);
}




